package com.cn.study.second.stage.code3.zuoye3;

public class Consumption {
    private int callTime;
    private int internetTraffic;
    private int expenses;
    /**
     *  callTime            统计通话时长
     *  internetTraffic     统计上网流量
     *  expenses            统计消费金额
     */

    Consumption() {
    }

    public Consumption(int callTime, int internetTraffic, int expenses) {
        setCallTime(callTime);
        setInternetTraffic(internetTraffic);
        setExpenses(expenses);
    }

    public int getCallTime() {
        return callTime;
    }

    public void setCallTime(int callTime) {
        this.callTime = callTime;
    }

    public int getInternetTraffic() {
        return internetTraffic;
    }

    public void setInternetTraffic(int internetTraffic) {
        this.internetTraffic = internetTraffic;
    }

    public int getExpenses() {
        return expenses;
    }

    public void setExpenses(int expenses) {
        this.expenses = expenses;
    }
    public void countCallTime(int quantity,int expenses,PhoneCard PhoneCard){
        //  统计通话时长
        if(PhoneCard.getCallTime() == 0){
            PhoneCard.setCallTime(quantity);    //  初次通话时间
        }else {
            setCallTime(PhoneCard.getCallTime()+quantity);
            PhoneCard.setCallTime(getCallTime());   //  登记历史通话时间
        }
        PhoneCard.setAccountBalance(PhoneCard.getAccountBalance()-(quantity*expenses));
        System.out.println("============================历史通话时间==================================");
        System.out.printf("历史通话时间：%d分钟，账户余额%d元\n",PhoneCard.getCallTime(),PhoneCard.getAccountBalance());
    }
    public void countInternetTraffic(int quantity,int expenses,PhoneCard PhoneCard){
        //  统计上网流量
        if(PhoneCard.getInternetTraffic() == 0){
            PhoneCard.setInternetTraffic(quantity);    //初次登记历史通话时间
        }else {
            setInternetTraffic(PhoneCard.getInternetTraffic()+quantity);
            PhoneCard.setInternetTraffic(getInternetTraffic());
        }
        PhoneCard.setAccountBalance(PhoneCard.getAccountBalance()-(quantity*expenses));
        System.out.println("==========================历史流量使用情况================================");
        System.out.printf("历史流量使用情况：%dGB,账户余额%d元\n",PhoneCard.getInternetTraffic(),PhoneCard.getAccountBalance());
    }

}